package com.school.test.search.function.assist;

import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @author 马洁
 * @date 2019/12/24 - 23:02
 */
public class MongoListDeal {
    public static void addToRes(Pattern regStr,
                         final List<? extends String> list,
                         final Collection<? super String> collection) {

        if (list.size() == 1) {
            collection.add(list.get(0));
        } else {
            list
                .forEach(item -> {
                    if (Pattern.matches(regStr.pattern(), item.trim())) {
                        collection.add(item);
                    }
                });
        }

    }
}
